package com.cz.nongyetongv5.adapter;

import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.cz.nongyetongv5.activity.NewListItemFragment;
import com.cz.nongyetongv5.activity.NewsListActivity;
import com.cz.nongyetongv5.bean.NewsTitle;

public class NewsListPagerAdapter extends FragmentPagerAdapter {

	private List<NewsTitle> titles = null;

	private NewsListActivity newsListActivity = null;

	public NewsListPagerAdapter(FragmentManager fm, List<NewsTitle> titles,
								NewsListActivity newsListActivity) {

		super(fm);

		this.titles = titles;

		this.newsListActivity = newsListActivity;
	}

	@Override
	public Fragment getItem(int position) {

		NewListItemFragment fragment = NewListItemFragment.getNewInstance(
				titles.get(position), newsListActivity);

		return fragment;
	}

	@Override
	public int getCount() {

		return titles.size();
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return titles.get(position).getName();
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

}
